package com.xinyu.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @ClassName: BaseResult
 * @Description: 封装返回值
 * @author: XinYu
 * @date: 2025/2/17
 * @since: (jdk_1.8)
 */
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class BaseResult {
    private Integer code;
    private String msg;
    private Object data;
    private Integer total;

    public BaseResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public BaseResult(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static BaseResult ok(Object data, Integer total){
        return new BaseResult(1,"成功",data,total);
    }

    public static BaseResult ok(){
        return new BaseResult(1,"成功");
    }

    public static BaseResult ok(Object data){
        return new BaseResult(1,"成功",data);
    }

    public static BaseResult ok(String msg,Object data){
        return new BaseResult(1,msg,data);
    }

    public static BaseResult error(){
        return new BaseResult(0,"失败");
    }

    public static BaseResult error(String msg){
        return new BaseResult(0,msg);
    }
}